//
//  YTClient.h
//  tesDemo02
//
//  Created by 拓客营 on 2022/3/23.
//

#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN

@interface YTUser : NSObject <NSCopying, NSCoding>

/// 用户ID
@property (nonatomic, copy) NSString *user_id;
/// 用户昵称
@property (nonatomic, copy) NSString *user_name;
/// 用户token
@property (nonatomic, copy) NSString *token;
/// 用户手机号
@property (nullable, nonatomic, copy) NSString *account;
/// token过期时间
@property (nonatomic, assign) NSInteger expires_time_stamp;
/// 会员等级
@property (nonatomic, assign) NSInteger level;
/// 会员过期时间
@property (nonatomic, assign) NSInteger member_expires;
/// 刷新token
@property (nonatomic, copy) NSString *refresh_token;

@end

@interface YTClient : NSObject <NSCopying, NSMutableCopying>


@property (nullable, nonatomic, strong, readonly) YTUser *user;

///<判断是否为会员>
@property (nonatomic, getter=isMember, readonly) BOOL member;

///< 判断是否登录~
@property (nonatomic, getter=isLogin, readonly) BOOL login;

+ (YTClient *)shared;
//#endif

- (instancetype)init NS_UNAVAILABLE;
+ (instancetype)new NS_UNAVAILABLE;

///< 根据指定路径创建一个客户端
- (instancetype)initWithPath:(NSString *)path;

///< 将网络请求结果中的数据格式化~ (使用了YYModel)
- (nullable YTUser *)userWithDict:(NSDictionary *)dict;
//- (nullable BKJPushSetting *)JPushSettingWithDict:(NSDictionary *)dict;

///< 更新本地用户数据
- (BOOL)updateUser:(YTUser *)user;

/// 登录 数据处理
- (void)loginInWithData:(id)responseObject;

///< 退出登录~ 删除所有的数据 主线程~
- (BOOL)logout;

///< 退出登录，如果本地删除操作有误，可以查看打印消息
- (void)logoutWithCompletionHandler:(nullable void(^)(BOOL flag, NSError *_Nullable error))completionHandler;

///< 推出登录界面
- (void)presentLoginControllerFrom:(UIViewController *)controller showClose:(BOOL)showClose;

@property (nonatomic, assign) BOOL isShowingLogin;// 登录界面是否弹出


#pragma mark - 心跳相关

// 登录后的心跳接口
-(void)heartbeatStrar;

-(void)heartbeatEnd;

@end

NS_ASSUME_NONNULL_END
